//
//  ViewController.m
//  InstrumentPanel
//
//  Created by nav on 16/6/24.
//  Copyright © 2016年 Chris.C. All rights reserved.
//

#import "ViewController.h"
#import "Panel.h"
#import <math.h>
@interface ViewController ()
{
    Panel *panel;
    UIImageView *img;
}
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor grayColor];
    panel = [[Panel alloc]initWithFrame:CGRectMake(100, 100, 200, 200)];
    panel.backgroundColor = [UIColor clearColor];
    
    [self.view addSubview:panel];
    
    
    //项目实际应用的时候仪表盘背景可使用图片 包括指针  只需要算好角度  旋转指针图片就可以了
    [self config];
    
}


- (void)config
{
    img = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 5, 100)];
    img.backgroundColor = [UIColor orangeColor];
    img.layer.anchorPoint = CGPointMake(0.5, 1);
    img.layer.position = CGPointMake(CGRectGetWidth(panel.frame), CGRectGetWidth(panel.frame) + 20);//图片y坐标下移20
    img.transform = CGAffineTransformMakeRotation(-(M_PI_2)*4/3);
    [self.view addSubview:img];
    
}

- (IBAction)changeg:(UISlider *)sender {
    NSLog(@"%f",M_PI_2);
    [panel setIndicatorTransform:(sender.value) * (M_PI_2)/(90)];
    img.transform = CGAffineTransformMakeRotation((sender.value) * (M_PI_2)/(90));
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
@end
